<template>
    <div>
    <div class="wrapper">
        <div class="header">
            <div>
                <a href="/home">首页 > </a><a href="/MoreGoods/new">新品 > </a><a href="javascript:;"> {{ goodDetil.title }} </a>
            </div>
            <div>
                <a href="/MoreGoods/new" class="icon" title="返回新品列表">
                <i class="el-icon-menu"></i>
                <i class="el-icon-arrow-right"></i>
            </a>
            </div>
            
        </div>
        <div class="container">
            <div    class="goodImg"
                    :style="{backgroundImage:'url(' + picBaseUrl + goodDetil.imgUrl + ')'}"
            ></div>
            <div class="goodMsg">
                <span class="goodTitle">{{ goodDetil.title }}</span>
                 <span style="padding:0"><span class="goodPrice">单价：￥ {{ goodDetil.curPrice }} </span> <del>￥ {{ goodDetil.price }}</del> </span>             
                <!-- <span>{{ goodDetil.price }}</span> -->
                <span class="goodSales">销量：{{ goodDetil.sales }} 🔥 </span>
                <span>库存：{{ goodDetil.stock }}</span>
                <span>厂家：{{ goodDetil.name }}</span>
                <span>商品描述：{{ goodDetil.goodsDescribe }}</span>
                <span>❤️ {{ goodDetil.fans }}</span>
                <span>商品类别：{{ goodDetil.category }}</span>      
                <div class="addCart">
                    <el-input-number v-model="num" :min="1" :max="parseInt(goodDetil.stock)" label="描述文字"></el-input-number>
                    <a href="javascript:;" class="addBtn" @click="addInCart(goodDetil)">添加到购物车</a>
                </div>      
            </div>
            

        </div>
        <Footer></Footer>
    </div>
    </div>
</template>

<script>
import http from '../../utils/http'
import Footer from '../foot.vue'

export default {
    data() {
        return {
            goodDetil:[],
            picBaseUrl:http.picBaseUrl,
            num: 0,
        };
    },
    components:{
        Footer
    },
    created () {
        this.goodDetil = this.$route.query
        // console.log(this.$route.query)
    },
    methods: {
        addInCart(goodDetil){            
            localStorage.setItem(`good`,JSON.stringify(goodDetil))
            console.log(goodDetil)
        }
    }
}
</script>

<style lang="scss" scoped>
    .wrapper{
        width: 100%;
        height: 50px;
        background: #f6f6f8;
    }
    .header{
        margin: 0 auto;
        width: 60%;
        height: 50px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        a{
            font-size: 13px;
            color: #222222;
            transition: .5s;
        }
        .icon{ 
            font-size: 16px;
        }         
        .icon:hover{
            color: #ef648c;
        }
    }
    .container{
        margin: 40px auto;
        width: 60%;
        display: flex;
        .goodImg{
            width: 50%;
            height: 680px;
            background: cyan;
            background-size: 100% 100%;
                    
        }
        .goodMsg{
                width: 50%;
                display: flex; 
                flex-direction: column; 
                margin-left: 20px;
            span{
                font-size: 18px;
                padding: 10px 5px;
                display: inline-block;
            }
            .goodTitle{
                font-size: 20px;
                font-weight: 500;
            }
            .goodPrice{
                font-size: 20px;
                font-weight: 700;
                padding: 10px 5px
            }
            .goodSales{
                font-size: 20px;
                font-weight: 500;
            }
        }
        .addCart{
            margin: 70px 0;
            width: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            .addBtn{
                margin: 0 30px;
                border-radius: 10px;
                line-height: 40px;
                text-align: center;
                color: #fff;
                background: #000;
                width: 160px;
                height: 40px;
                font-size: 15px;
                font-weight: 800;
            }
        }
        
    }
</style>